class Command(private val comRelation: Com_relation) :Com_relation{
    var list: String = "E:\\学习kotlin\\mingling\\src"
    var words: MutableList<String> = mutableListOf()
    var com:String=""
    fun start(){
        words.clear()  // 清空之前的命令
        var i = 1
        var a = ""
        for ((index, char) in com.withIndex()) {
            if (i == 1 && char == ' ') {
                continue
            } else {
                i = 2
                if (char == ' ' || index == com.length - 1) {
                    if (char != ' ') {
                        a += char
                    }
                    words.add(a)
                    a = ""
                    i = 1
                } else {
                    a += char
                }
            }
        }
        tooltoneed(words,list)
        if (words.isNotEmpty()) {
            when (words[0]) {
                "ls" -> comRelation.ls()
                "pwd" -> comRelation.pwd()
                "mkdir" -> comRelation.mkdir()
                "cd" -> comRelation.cd()
                "rm" -> comRelation.rm()
                "cp" -> comRelation.cp()
                "mv" -> comRelation.mv()
                "rn" -> comRelation.rn()
                else -> println("输入错误，请重新输入")
            }
        } else {
            println("输入错误，请重新输入")
        }
        list=commandtoneed()
        return
    }

    override fun commandtoneed(): String {
        return comRelation.commandtoneed()
    }
    override fun ls() {
        comRelation.ls()
    }

    override fun pwd() {
        comRelation.pwd()
    }

    override fun mkdir() {
        comRelation.mkdir()
    }

    override fun cd() {
        comRelation.cd()
    }

    override fun rm() {
        comRelation.rm()
    }

    override fun cp() {
        comRelation.cp()
    }

    override fun mv() {
        comRelation.mv()
    }

    override fun rn() {
        comRelation.rn()
    }

    override fun tooltoneed(words: MutableList<String>, list: String) {
        comRelation.tooltoneed(words,list)
    }

}